POV-Ray : Newsgroups : povray.binaries.images : Re: Moss Vine test [~30k] : Re: Moss Vine test [~30k] Server Time
1 Aug 2024 04:11:27 EDT (-0400)
  Re: Moss Vine test [~30k]  
From: clipka
Date: 12 Mar 2009 11:20:00
Message: <web.49b92730d4fd5b28f708085d0@news.povray.org>
"[GDS|Entropy]" <gds### [at] hotmailcom> wrote:
> Those are very interesting results, not all expected. Apparently, good
> programming concepts are not always good POV concepts... Unfortunately there
> appears to be a performance penalty for writing things extensibly using
> certian methods. :-(

As a matter of fact, I'd partially blame it on POV. With a few changes to
interior design, I guess it should be possible to copy CSG objects, too,
without copying each and every of its components.

At the moment however, it seems to me that the design of the bounding box
mechanism prohibits this (requiring a dedicated bounding box per primitive, and
each box in turn referencing a dedicated primitive object), so changes would
have to be made there.


> Do you (or anyone) have any ideas on how to perform an efficient inside()
> test on not just a single point, but an entire object? You can see the issue
> in my last image post, where even with an inside() test, the actual leaf
> objects occur partially within the cyl at certian points, even when the
> vector/normal reorient may not occur within the cyl.
>
> At first glance it looks like a loop covering an array of vectors within
> min/max extent of whatever object A you are trying to determine may or may
> not occur within another object B is the only option (and then ditch
> creating the object at the vector which would produce such a coincident
> result), but that seems awfully crude. :-\

If I understand you correctly, you'd loop in 3D.

Here's a way to reduce this to 2D at least:

Loop over (or pick random points on) a sphere surface big enough to contain all
of your object A. (make sure you get a roughly homogenous distribution, and
don't waste too much time near the poles)

trace() a ray from each point to the object's bounding box center.

If you get an intersection point, test whether it is inside the other object B.

Repeat until you're confident that you've covered enough of object A's surface.

Note that this way you may miss surface areas in hollows; however, if the other
object is "convex enough", this should not be a problem. It will be a real
issue only if both objects have significant hollows.


Another approach - which should be able to cope with arbitrary hollows - would
be to actually test whether intersection{A B} contains anything. Note however
that this will again create another object. (Mental note for myself: Test
whether #undef frees the memory occupied by the assigned object.)


If you want to place a bucketload of identical objects, you may want to use the
former approach, but shoot the rays at the "unplaced" object and store them in
an array. When you then try to place a copy, you loop through the array,
transform the points according to the intended placement, and do the inside
test for each transformed point. You'd then add the transformed object only if
you're confident that it doesn't intersect. This spares you both a lot of
trace() invocations and some unnecessary instantiating of objects that turn out
to intersect.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.